<?php
declare (strict_types = 1);

namespace app\api\controller;
use app\model\BasePostLabelsModel;
use think\App;


class PostLabels extends Base {

    private $req;

    private $basePostLabelsModel;

    private $page;

    private $limit = 10;


    public function __construct(App $app)
    {
        parent::__construct($app);

        $this->req = request()->param();

        $this->page = isset($this->req['page']) ? $this->req['page']  : 1;

        $this->limit = isset($this->req['limit']) ? $this->req['limit']  : 10;

        $this->basePostLabelsModel = new BasePostLabelsModel();

    }



    /*
     * 获取标签列表
     * */

    public function getList()
    {
        $where=[];

        $where[] = ["is_delete","=",0];

        if(isset($this->req["word"]) && !empty($this->req["word"])){
            $where[] = ['label_name','LIKE',"%{$this->req['word']}%"];
        }

        $list = $this->basePostLabelsModel->getList($where,$this->page,$this->limit,[]);

        $total = $this->basePostLabelsModel->getTotal($where);

        return $this->succData($total,$list);
    }

}
